﻿namespace Dissemination.MVC.Repositories
{
    using System.Linq;
    using System.Collections.Generic;
    using Dissemination.MVC.Models;

    public class ParticipantRepository : BaseRepository<Participant>
    {
        public ParticipantRepository()
        {
            EntityName = "Participants";
        }

        public override List<Participant> List()
        {
            return dataContext.Participants.ToList();
        }

        public Seminar GetSeminarByID(int seminarID)
        {
            return 
                dataContext.Seminars.FirstOrDefault(
                s => s.SeminarID == seminarID);
        }

        public Gender GetGenderByID(int genderID)
        {
            return 
                dataContext.Genders.FirstOrDefault(
                g => g.GenderID == genderID);
        }

        public ProfessionalBackground GetProfessionalBackgroundByID(int professionalBackgroundID)
        {
            return 
                dataContext.ProfessionalBackgrounds.FirstOrDefault(
                pb => pb.ProfessionalBackgroundID == professionalBackgroundID);
        }

        public Speciality GetSpecialityByID(int specialityID)
        {
            return
                dataContext.Specialities.FirstOrDefault(
                s => s.SpecialityID == specialityID);
        }


        public List<Gender> ListGenders()
        {
            return dataContext.Genders.ToList();
        }

        public List<Speciality> ListSpecialities()
        {
            return dataContext.Specialities.ToList();
        }

        public List<ProfessionalBackground> ListProfessionalBackgrounds()
        {
            return dataContext.ProfessionalBackgrounds.ToList();
        }

        public override Participant Get(int id)
        {
            return dataContext.Participants.Include("Gender").Include("Seminar").Include("Speciality").Include("ProfessionalBackground").FirstOrDefault(p => p.ParticipantID == id);
        }
    }
}
